package com.zpself.module.JDK8新功能.日期时间新API;

import org.junit.Test;

import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author By ZengPeng
 * @Description DateTimeFormatter 用final修饰
 * @date in  2021/3/2 16:15
 * @Modified By
 */
public class DateTimeFormatter为什么线程安全 {
    @Test
    public void test(){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");

        ZonedDateTime zdt = ZonedDateTime.now();
        System.out.println(formatter.format(zdt));

        LocalDateTime ldt = LocalDateTime.now();
        System.out.println(ldt.format(formatter));
    }
}
